namespace MESData.ProductionPlan.API.DTO
{
    /// <summary>
    /// 生产计划DTO
    /// </summary>
    public class ProductionPlanDto
    {
        /// <summary>
        /// 计划单号
        /// </summary>
        public string PlanNumber { get; set; } = string.Empty;
        
        /// <summary>
        /// 计划主题
        /// </summary>
        public string PlanSubject { get; set; } = string.Empty;
        
        /// <summary>
        /// 单据日期
        /// </summary>
        public DateTime DocumentDate { get; set; }
        
        /// <summary>
        /// 关联销售订单ID（兼容旧入参，可为空）
        /// </summary>
        public int? SalesOrderId { get; set; }
        
        /// <summary>
        /// 关联项目ID
        /// </summary>
        public int? ProjectId { get; set; }
        
        /// <summary>
        /// 备注
        /// </summary>
        public string? Remarks { get; set; }
        
        /// <summary>
        /// 是否绑定销售订单
        /// </summary>
        public bool IsBindSalesOrder { get; set; } = true;
        
        /// <summary>
        /// 生产物品列表（自由录入）
        /// </summary>
        public List<ProductedItemDto> ProductedItems { get; set; } = new List<ProductedItemDto>();
        
        /// <summary>
        /// 附件列表
        /// </summary>
        public List<ProductionPlanAttachmentDto> Attachments { get; set; } = new List<ProductionPlanAttachmentDto>();
        
        /// <summary>
        /// 批量选择的物品ID集合（将写入ProductionPlanItem）
        /// </summary>
        public List<int> SelectedItemIds { get; set; } = new List<int>();
        
        /// <summary>
        /// 批量选择的销售订单ID集合（将写入ProductionPlanSalesOrder）
        /// </summary>
        public List<int> SelectedSalesOrderIds { get; set; } = new List<int>();
    }

    /// <summary>
    /// 生产物品DTO
    /// </summary>
    public class ProductedItemDto
    {
        /// <summary>
        /// 物品编号
        /// </summary>
        public string ItemNumber { get; set; } = string.Empty;
        
        /// <summary>
        /// 物品名称
        /// </summary>
        public string ItemName { get; set; } = string.Empty;
        
        /// <summary>
        /// 规格型号
        /// </summary>
        public string SpecificationModel { get; set; } = string.Empty;
        
        /// <summary>
        /// 单位
        /// </summary>
        public string Unit { get; set; } = string.Empty;
        
        /// <summary>
        /// 物品类别
        /// </summary>
        public string ItemCategory { get; set; } = string.Empty;
        
        /// <summary>
        /// 物品分类
        /// </summary>
        public string ItemClassification { get; set; } = string.Empty;
        
        /// <summary>
        /// 品牌
        /// </summary>
        public string? Brand { get; set; }
        
        /// <summary>
        /// 计划数量
        /// </summary>
        public int Quantity { get; set; }
        
        /// <summary>
        /// 详情日期
        /// </summary>
        public DateTime? DetailDate { get; set; }
        
        /// <summary>
        /// 主单位数量
        /// </summary>
        public int? MainUnitQuantity { get; set; }
        
        /// <summary>
        /// 备注
        /// </summary>
        public string? Remarks { get; set; }
    }

    /// <summary>
    /// 生产计划附件DTO
    /// </summary>
    public class ProductionPlanAttachmentDto
    {
        /// <summary>
        /// 文件名
        /// </summary>
        public string FileName { get; set; } = string.Empty;
        
        /// <summary>
        /// 文件路径
        /// </summary>
        public string FilePath { get; set; } = string.Empty;
        
        /// <summary>
        /// 文件大小
        /// </summary>
        public long FileSize { get; set; }
        
        /// <summary>
        /// 文件类型
        /// </summary>
        public string FileType { get; set; } = string.Empty;
    }

    public class ProductionPlanDetailDto
    {
        public int Id { get; set; }
        public string PlanNumber { get; set; } = string.Empty;
        public string PlanSubject { get; set; } = string.Empty;
        public DateTime DocumentDate { get; set; }
        public int? SalesOrderId { get; set; }
        public int? ProjectId { get; set; }
        public string? Remarks { get; set; }
        public string Status { get; set; } = string.Empty;
        public bool IsBindSalesOrder { get; set; }
        public string? Creator { get; set; }
        public DateTime CreateTime { get; set; }
        public string? Updator { get; set; }
        public DateTime? UpdateTime { get; set; }
        public List<ProductedItemDto> ProductedItems { get; set; } = new();
        public List<ProductionPlanAttachmentDto> Attachments { get; set; } = new();
        public List<ProductionPlanOperationLogDto> OperationLogs { get; set; } = new();
    }

    public class ProductionPlanOperationLogDto
    {
        public DateTime OperationTime { get; set; }
        public string Operator { get; set; } = string.Empty;
        public string OperationContent { get; set; } = string.Empty;
    }

    /// <summary>
    /// 生产计划分页查询参数
    /// </summary>
    public class ProductionPlanQueryDto
    {
        /// <summary>
        /// 页码（从1开始）
        /// </summary>
        public int PageIndex { get; set; } = 1;

        /// <summary>
        /// 每页大小
        /// </summary>
        public int PageSize { get; set; } = 10;

        /// <summary>
        /// 计划单号（模糊查询）
        /// </summary>
        public string? PlanNumber { get; set; }

        /// <summary>
        /// 计划主题（模糊查询）
        /// </summary>
        public string? PlanSubject { get; set; }

        /// <summary>
        /// 单据日期开始
        /// </summary>
        public DateTime? DocumentDateStart { get; set; }

        /// <summary>
        /// 单据日期结束
        /// </summary>
        public DateTime? DocumentDateEnd { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public string? Status { get; set; }
    }

    /// <summary>
    /// 生产计划分页查询结果
    /// </summary>
    public class ProductionPlanPageResultDto
    {
        /// <summary>
        /// 总记录数
        /// </summary>
        public int TotalCount { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int TotalPages { get; set; }

        /// <summary>
        /// 当前页码
        /// </summary>
        public int PageIndex { get; set; }

        /// <summary>
        /// 每页大小
        /// </summary>
        public int PageSize { get; set; }

        /// <summary>
        /// 数据列表
        /// </summary>
        public List<ProductionPlanListItemDto> Items { get; set; } = new();
    }

    /// <summary>
    /// 生产计划列表项DTO
    /// </summary>
    public class ProductionPlanListItemDto
    {
        public int Id { get; set; }
        public string PlanNumber { get; set; } = string.Empty;
        public string PlanSubject { get; set; } = string.Empty;
        public DateTime DocumentDate { get; set; }
        public string? SalesOrderSubject { get; set; }
        public string? ProjectName { get; set; }
        public string? Remarks { get; set; }
        public string Status { get; set; } = string.Empty;
        public bool IsBindSalesOrder { get; set; }
        public string? Creator { get; set; }
        public DateTime CreateTime { get; set; }
        public string? Updator { get; set; }
        public DateTime? UpdateTime { get; set; }
    }
} 